<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Administrator
 * Date: 13-9-14
 * Time: 上午10:53
 * To change this template use File | Settings | File Templates.
 */

abstract class CommonModel extends RelationModel
{
    protected $total = 0; //记录总数
    protected $rows = array(); //记录

    public function fetch_datagrid()
    {
        $page = isset($_REQUEST['page']) && $_REQUEST['page'] > 0 ? intval($_REQUEST['page']) : 1;
        $rows = isset($_REQUEST['rows']) && $_REQUEST['rows'] > 0 ? intval($_REQUEST['rows']) : 10;
        if(method_exists($this, '_before_fetch_datagrid')) $this->_before_fetch_datagrid($page, $rows);
        return array('total' => $this->total, 'rows' => $this->rows);
    }
}